package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "demoTest",tags = "测试接口")
@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired private IndexService indexService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public JSONObject addUser(@RequestBody JSONObject requestJson){
        return indexService.addUser(requestJson);
    }

    @ApiOperation("查询列表")
    @PostMapping("/list")
    public JSONObject listUser(){
        return indexService.listUser();
    }

    @ApiOperation("更新")
    @PostMapping("/update")
    public JSONObject updateUser(@RequestBody JSONObject requestJson){
        return indexService.updateUser(requestJson);
    }

    @ApiOperation("删除")
    @PostMapping("/del")
    public JSONObject deleteUser(@RequestBody JSONObject requestJson){
        return indexService.deleteUser(requestJson);
    }
}
